package com.xiaoxi.exam.controller;

import cn.xinzhili.xutils.core.http.Response;
import com.xiaoxi.exam.bean.OrderInfo;
import com.xiaoxi.exam.bean.TotalResutl;
import com.xiaoxi.exam.bean.enums.ExamType;
import com.xiaoxi.exam.model.Account;
import com.xiaoxi.exam.service.AccountService;
import com.xiaoxi.exam.service.OrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/seat")
public class GetSeatController {

  @Autowired
  private OrderService orderService;
  @Autowired
  private AccountService accountService;

  @RequestMapping("/total")
  public Response getTotalOrder() {
    TotalResutl totalResutl = new TotalResutl();
    totalResutl.setTotal(orderService.totalEnablePreorders());
    return Response.instanceSuccess(totalResutl);
  }

  @RequestMapping("/infos")
  @ApiImplicitParams({
      @ApiImplicitParam(paramType = "query", name = "pageAt", value = "第几页", required = true, dataType = "Integer"),
      @ApiImplicitParam(paramType = "query", name = "pageSize", value = "页内数量", required = true, dataType = "Integer"),
      @ApiImplicitParam(paramType = "query", name = "type", value = "考试类型 TOEFL IETLS", required = true, dataType = "String")
  })
  public List<OrderInfo> getOrderInfos(@RequestParam("pageAt") Integer pageAt,
      @RequestParam("pageSize") Integer pageSize) {
    return orderService.getPreorderLists(pageAt, pageSize);
  }

  @RequestMapping("/account")
  public Account getAccount(@RequestParam("userId") Long userId) {
    return accountService.getAccountByUserId(userId);
  }


}
